/*
 *  Copyright 2009 Utkin Dmitry
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
 
/* 
 *  This file is part of the WSF Staff project.
 *  Please, visit http://code.google.com/p/staff for more information.
 */

// This file generated by staff_codegen
// Client skeleton

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <memory>
#include <staff/utils/stringutils.h>
#include <staff/utils/Log.h>
#include <staff/common/Exception.h>
#include <staff/utils/console.h>
#include <staff/common/Exception.h>
#include <staff/client/ServiceFactory.h>
#include "CalcService.h"

int main(int /*nArgs*/, const char* /*paszArgs*/[])
{
  try
  {
    // use anonymous account and instance "mycalc"
    std::auto_ptr< ::samples::calc::CalcService > pCalcService(staff::ServiceFactory::Inst().GetService< ::samples::calc::CalcService >("", "", "mycalc"));

    STAFF_ASSERT(pCalcService.get(), "Cannot get client for service calc.CalcService!");

    // Invoke Your service here:
    staff::LogInfo() << "1 + 2 = " << pCalcService->Add(1, 2);

    staff::LogInfo() << "3 - 1 = " << pCalcService->Sub(3, 1);

    staff::LogInfo() << "Saved service mem: " << pCalcService->GetMem();

    srand(static_cast<unsigned int>(time(NULL)));
    int nNewMem = rand() % 100;

    staff::LogInfo() << "Setting mem: " << nNewMem;
    pCalcService->SetMem(nNewMem);
    staff::LogInfo() << pCalcService->GetMem();
    staff::LogInfo() << "Service mem: " << pCalcService->GetMem();
  }
  STAFF_CATCH_ALL

  return 0;
}
